package com.wc.alorithm_luogu.P5723;

import java.util.ArrayList;
import java.util.Scanner;

/**
 * @Author congge
 * @Date 2023/4/20 11:42
 * @description https://www.luogu.com.cn/problem/P5723
 * 质数口袋
 */
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int L = sc.nextInt();

        // packet口袋
        ArrayList<Integer> packet = new ArrayList<>();

        Main main = new Main();
        int curNum = 2;

        int sum = 0;
        while (sum <= L) {
            if (main.isPrime(curNum)) {
                sum += curNum;
                packet.add(curNum);
            }
            curNum++;
        }
        // 删除掉最后一个
        packet.remove(packet.size() - 1);

        for (int num : packet) {
            System.out.println(num);
        }
        System.out.println(packet.size());
    }

    /**
     * 判断num是否为质数
     * @param num
     * @return
     */
    public boolean isPrime(int num) {
        if (num == 1) {
            return false;
        }

        int mid = (int) Math.pow(num, 0.5);

        for (int i = 2; i <= mid; i++) {
            if (num % i == 0) {
                return false;
            }
        }

        return true;
    }
}
